#ifndef __FRMDISPLAY_H__
#define __FRMDISPLAY_H__

#include "stm32f1xx.h"
#include "ModbusRegister.h"

#define DEF_CLEARFORM          0
#define DEF_MODIFYFORM1        1
#define DEF_TESTFORM           2
#define DEF_RELAYTESTFORM      3
#define DEF_MAINFORM           4
#define DEF_TRIP_FORM          5
#define DEF_EXTRA_INFO_FORM    6
#define DEF_MODIFYFORM         7
#define DEF_SENSORFORM         8
#define DEF_CONTROLFORM        9
#define DEF_COMPRESSORFORM     10
#define DEF_DEFROSTFORM        11
#define DEF_ALARMFORM          12
#define DEF_FANFORM            13
#define DEF_LIGHTFORM          14
#define DEF_SYSTEMFORM         15
#define DEF_BTCLOCKFORM        16
#define DEF_DTCLOCKFORM        17
#define DEF_FTCLOCKFORM        18
#define DEF_LTCLOCKFORM        19
#define DEF_NTCLOCKFORM        20
#define DEF_CTRMODIFYFORMM     21
#define DEF_HEATERFORM 					4
#define DEF_PASSWORDFORM				5
#define DEF_PANORAMAFORM				6
#define DEF_SPEEDSETFORM				26
#define DEF_MODIFYFORM2					27
#define DATA_DISPLAY						1
#define SENSOR_PARA							2
#define COMPRESSOR_PARA					3
#define DEFROST_PARA						4
#define ALARM_PARA							5
#define FAN_PARA								6
#define VAVLE_PARA							7
#define LIGHT_PARA							8
#define DEW_PARA								9
#define SYSTEM_PARA							10
#define CLOCK_PARA							11


#define CONTROL_START  HREG_CONTROL_SET_POINT
#define CONTROL_STOP  HREG_NSB_MODE_SETPOINT_UP_DEVIATION

#define ALARM_START HREG_HIGH_ALARM_TEMP 
#define ALARM_STOP  HREG_EXTERN_WARN_DELAY

#define DEFROST_START  HREG_DEFROST_MODE
#define DEFROST_STOP  HREG_DEFROST_TIMER12

#define SYSTEM_START HREG_LOCK_MODE 
#define SYSTEM_STOP   HREG_DAY_STOP4 //HREG_LIGHTING_STOP_TIMER4

//#define CONTROL_START  HREG_SETPOINT_MIN
//#define CONTROL_STOP  HREG_REMOTE_ON_OFF

#define COMPRESSOR_START  HREG_COMPRESSOR_WAIT_TIMER
#define COMPRESSOR_STOP  HREG_COMPRESSOR2_ON_DELEAY_TIMER

//#define DEFROST_START  HREG_DEFROST_Mode
//#define DEFROST_STOP  HREG_DEFOST_MANUAL


//#define ALARM_START HREG_HIGH_ALARM_TEMP 
//#define ALARM_STOP  HREG_DOOR_OPEN_WARN_DELAY

#define FAN_START HREG_EVAPORATOR_FAN_MODE
#define FAN_STOP  HREG_ANTI_DEW_CONTROL_COMM


#define LIGHT_START HREG_LIGHTING_MODE  
#define LIGHT_STOP  HREG_LIGHTING_STOP_TIMER4


//#define SYSTEM_START HREG_ADDRESS 
//#define SYSTEM_STOP   HREG_BZ_SET

#define BT_START HREG_ON_START1  
#define BT_STOP  HREG_ON_STOP5

#define DT_START HREG_DEFROST_TIMER1  
#define DT_STOP  HREG_DEFROST_TIMER12

//#define FT_START HREG_ANTI_DEW_START1  
//#define FT_STOP  HREG_ANTI_DEW_STOP5

#define LT_START HREG_LIGHTING_START_TIMER1
#define LT_STOP  HREG_LIGHTING_STOP_TIMER4


#define NT_START HREG_NSB_START_TIMER1  
#define NT_STOP  HREG_NSB_STOP_TIMER5

//purview
#define PURVIEW_ERROR_VIEW      0
#define PURVIEW_USER_VIEW       1
#define PURVIEW_ADMIN_VIEW      2
#define PURVIEW_ENGINEER_VIEW   3

//#define SENSOR_PURVIEW_USER_VIEW_COUNT         (SENSOR_STOP - SENSOR_START + 1)
//#define SENSOR_PURVIEW_ADMIN_VIEW_COUNT        (SENSOR_STOP - SENSOR_START + 1)
//#define SENSOR_PURVIEW_ENGINEER_VIEW_COUNT     (SENSOR_STOP - SENSOR_START + 1)

#define CONTROL_PURVIEW_USER_VIEW_COUNT         (CONTROL_STOP - CONTROL_START + 1)
#define CONTROL_PURVIEW_ADMIN_VIEW_COUNT        (CONTROL_STOP - CONTROL_START + 1)
#define CONTROL_PURVIEW_ENGINEER_VIEW_COUNT     (CONTROL_STOP - CONTROL_START + 1)

//#define COMPRESSOR_PURVIEW_USER_VIEW_COUNT         (COMPRESSOR_STOP - COMPRESSOR_START + 1)
//#define COMPRESSOR_PURVIEW_ADMIN_VIEW_COUNT        (COMPRESSOR_STOP - COMPRESSOR_START + 1)
//#define COMPRESSOR_PURVIEW_ENGINEER_VIEW_COUNT     (COMPRESSOR_STOP - COMPRESSOR_START + 1)

#define DEFROST_PURVIEW_USER_VIEW_COUNT         (DEFROST_STOP - DEFROST_START + 1)
#define DEFROST_PURVIEW_ADMIN_VIEW_COUNT        (DEFROST_STOP - DEFROST_START + 1)
#define DEFROST_PURVIEW_ENGINEER_VIEW_COUNT     (DEFROST_STOP - DEFROST_START + 1)

#define ALARM_PURVIEW_USER_VIEW_COUNT         (ALARM_STOP - ALARM_START + 1)
#define ALARM_PURVIEW_ADMIN_VIEW_COUNT        (ALARM_STOP - ALARM_START + 1)
#define ALARM_PURVIEW_ENGINEER_VIEW_COUNT     (ALARM_STOP - ALARM_START + 1)

//#define FAN_PURVIEW_USER_VIEW_COUNT         (FAN_STOP - FAN_START + 1)
//#define FAN_PURVIEW_ADMIN_VIEW_COUNT        (FAN_STOP - FAN_START + 1)
//#define FAN_PURVIEW_ENGINEER_VIEW_COUNT     (FAN_STOP - FAN_START + 1)

//#define LIGHT_PURVIEW_USER_VIEW_COUNT         (LIGHT_STOP - LIGHT_START + 1)
//#define LIGHT_PURVIEW_ADMIN_VIEW_COUNT        (LIGHT_STOP - LIGHT_START + 1)
//#define LIGHT_PURVIEW_ENGINEER_VIEW_COUNT     (LIGHT_STOP - LIGHT_START + 1)

#define SYSTEM_PURVIEW_USER_VIEW_COUNT         (SYSTEM_STOP - SYSTEM_START + 1)    
#define SYSTEM_PURVIEW_ADMIN_VIEW_COUNT        (SYSTEM_STOP - SYSTEM_START + 1)
#define SYSTEM_PURVIEW_ENGINEER_VIEW_COUNT     (SYSTEM_STOP - SYSTEM_START + 1)

//#define BTCLOCK_PURVIEW_USER_VIEW_COUNT         (BT_STOP - BT_START + 1)
//#define BTCLOCK_PURVIEW_ADMIN_VIEW_COUNT        (BT_STOP - BT_START + 1)
//#define BTCLOCK_PURVIEW_ENGINEER_VIEW_COUNT     (BT_STOP - BT_START + 1)

#define DTCLOCK_PURVIEW_USER_VIEW_COUNT         (DT_STOP - DT_START + 1)
#define DTCLOCK_PURVIEW_ADMIN_VIEW_COUNT        (DT_STOP - DT_START + 1)
#define DTCLOCK_PURVIEW_ENGINEER_VIEW_COUNT     (DT_STOP - DT_START + 1)

#define LTCLOCK_PURVIEW_USER_VIEW_COUNT         (LT_STOP - LT_START + 1)
#define LTCLOCK_PURVIEW_ADMIN_VIEW_COUNT        (LT_STOP - LT_START + 1)
#define LTCLOCK_PURVIEW_ENGINEER_VIEW_COUNT     (LT_STOP - LT_START + 1)

//#define FTCLOCK_PURVIEW_USER_VIEW_COUNT         (FT_STOP - FT_START + 1)
//#define FTCLOCK_PURVIEW_ADMIN_VIEW_COUNT        (FT_STOP - FT_START + 1)
//#define FTCLOCK_PURVIEW_ENGINEER_VIEW_COUNT     (FT_STOP - FT_START + 1)

//#define NTCLOCK_PURVIEW_USER_VIEW_COUNT         (NT_STOP - NT_START + 1)
//#define NTCLOCK_PURVIEW_ADMIN_VIEW_COUNT        (NT_STOP - NT_START + 1)
//#define NTCLOCK_PURVIEW_ENGINEER_VIEW_COUNT     (NT_STOP - NT_START + 1)



#define STRING_SIZE_MAX   			50

#define DISPLAY_RET_AIR_TEMP     1
#define DISPLAY_OUT_AIR_TEMP     0
#define DISPLAY_GOODS_TEMP     3
#define DISPLAY_VIRTUAL_TEMP     2
#define DISPLAY_CONTRIL_TEMP   4

#define STATUS_INIT 0
#define STATUS_RUN 1
#define STATUS_QUIT 2


#define SPACE    42
#define ONE_DOT  0x10
#define TWO_DOT  0x08
#define THREE_DOT  0x1

#define TIME_DOT  0x0c


#define DOT 46
#define NoSign 0
#define CelsiusSign 1
#define FahrSign 2

#define NUM0 48
#define NUM9 57


#define LED_1_2 0
#define LED_3_4 1
#define LED_5_6 2
#define LED_7_8 3
#define LED_SIGN1 4

#define	LED_1          0
#define	LED_9          8

#define	LED_14          13
#define	LED_21          20
#define	LED_22          21


#define	LED_COUNT      28
#define	LED_ALLON      1

#define	LED_ALLOFF     2

#define ModbusCommError       0x0200


#define NONE 0
#define SIGN1_ON   0x1


#define SIGN2_C    0x1
#define SIGN2_f    0x2
#define SIGN_ALL    0x3F

#define SIGN_D1    0x1
#define SIGN_D2    0x2
#define SIGN_D3    0x4
#define SIGN_D4    0x8

#define SIGN_D5    0x10


#define SIGN5_BAR    0x1
#define SIGN5_RH     0x2
#define SIGN5_ALL    0x3


#define POWERON           0x8000

extern char  *   *GA_FormString;
extern char     * StringCnA[];

extern char  *    *GB_FormString;
extern char     * StringCnB[];

extern char *    * GR_FormString;
extern char  * StringCnR[];

extern char  *   * DSBR_FormString;
extern char  *   StringDSBCnR[];

extern char  * *GT_FormString;
extern char     * StringCnT[];

extern char  *  *  GC_FormString;
extern char     * StringCnC[];

extern char  *  *  GD_FormString;
extern char     * StringCnD[];

extern char  *  * GE_FormString;
extern char     * StringCnE[];

extern char  *  *  GF_FormString;
extern char     * StringCnF[];

extern char  *  *  GG_FormString;
extern char     * StringCnG[];

extern char  *  *  GH_FormString;
extern char     * StringCnH[];

extern char  *  *  GI_FormString;
extern char     * StringCnI[];

extern char  *  *  GJ_FormString;
extern char  *   StringCnJ[];

extern char **Gbt_FormString;
extern char  *   StringCnbt[];

extern char  *  *  GdT_FormString;
extern char     * StringCndT[];

extern char  *  *  GFT_FormString;
extern char  *    StringCnFT[];

extern char  *  *  GNT_FormString;
extern char  *    StringCnNT[];

extern char  *  *  GLT_FormString;
extern char  *    StringCnLT[];

extern char  *  StringCnSS[];
extern char  * *  GSS_FormString;

extern char   * StringCnC1[];
extern char *  *GC1_FormString;

extern  char    * StringCnC2[];
extern   char  *   * GC2_FormString;

extern char  * StringCnC3[];
extern char  *   *  GC3_FormString;

extern char  * StringCnC4[];
extern char  *   *  GC4_FormString;

extern char  * StringCnC5[];
extern char  *   *  GC5_FormString;

extern char  * StringCnC6[];
extern char  *   *  GC6_FormString;

extern char  * StringCnC7[];
extern char  *   *  GC7_FormString;

extern char  *StringCnC8[];
extern char  *   *  GC8_FormString;

extern char  *StringCnC9[];
extern char  *   *  GC9_FormString;

extern char  * StringCnC10[];
extern char  *   *  GC10_FormString;

extern char  * StringCnC11[];
extern char  *   *  GC11_FormString;

extern char  * StringCnC12[];
extern char  *   *  GC12_FormString;

extern char  * StringCnC13[];
extern char  *   *  GC13_FormString;

extern char  * StringCnC14[];
extern char  *   *  GC14_FormString;

extern char  * StringCnC15[];
extern char  *   *  GC15_FormString;

extern char  *StringCnC16[];
extern char  *   *  GC16_FormString;

extern char  *StringCnC17[];
extern char  *   *  GC17_FormString;
extern char  *StringCnC18[];
extern char  *   *  GC18_FormString;
extern char  *StringCnC19[];
extern char  *   *  GC19_FormString;

extern char  *    StringCnLL[];
extern char  *   * GLL_FormString;

extern u16 ModifyCur;
extern s16 ValueToEdit;
extern u16 auto_return;
extern u16 SecUpdate;
extern s16 TimerCount;
extern s16 TimerLcokCount;
extern u8 SimpleSetFalg;
extern u8 DEC2;
extern u8 LightFlag;
extern u8 SensorDisPlay;

extern u8 FormStatus;
extern u16 SetupCur;
extern u8 FormTo;
extern u8 PrevForm;
extern u16 MaxCur;
extern u8 CaleSecond;
extern u8 LastForm;
extern u8 g_Purview;
extern u8 ActiveForm;
extern u16 KeyDownCount;
extern u8 DisPlayPosition;
extern u8 KeyInforDownCount;

extern void DisplayChars(char *str);
extern void Display_Init(void);
extern void DisplayAllOn(void);
extern void DisplayLEDNum(u8 Led , u8 Num);
extern void SymbolDisplay(u16 Status);
extern void Main_Form(void);
//extern void DisplayMainTempValues(s16 Value,u8 unit,u8 dec);
extern void DisplayAllOff(void);
extern  void DisplaySecondValues(s16 Value,u8 unit,u8 dec)  ; 
extern void DisplayMainValues(s16 Value,u8 unit,u8 dec);
extern void DisplayMainTempValues(s16 Value,u8 unit,u8 dec);
extern void  DisplayUnit(u8 Unit1 ,u8 Dec1,u8 Unit2 ,u8 Dec2);
extern void DisplayMainChars(char *str);
extern void DisplaySecondChars(char *str);
extern u8 Display_Update(void) ;
extern void Set_SetupFormPrevForm(u8 prevForm);
extern void DisplayRelayTestValues(u8 SerialNum,u8 RelayNum);
extern u16 Get_SetupCur(void);
extern void DisplaySensorTestValues(u8 SerialNum,s16 Value,u8 flag);
extern void StrCpy( char *src, char *dest);
extern char* GetParamDisplayName( char* fs);
extern void DisplayDotFlashChars(char *str  ,u8 DotFlsh);
extern void DisplayTwoCharNum(char *str , s16 Value);
extern void DisplayACharNum(char *str , s16 Value,u8 dec);
extern s16 TempChange(s16 ValueToEdit);
#endif
